
#include "stdafx.h"

#include "list键值插座.h"


using namespace std;






C_ivec3Map_UI32插座::C_ivec3Map_UI32插座(string name)
	:C_插座基类(name, E_插座类型::e_插座Type_MapiVec3_Uint32_Array1D)
{
}

C_ivec3Map_UI32插座::~C_ivec3Map_UI32插座()
{
}

void * C_ivec3Map_UI32插座::f_getData() {
	C_插座基类* socket = f_getLinkOutSocket();
	if (socket) {
		if (socket->m_Type == E_插座类型::e_插座Type_MapiVec3_Uint32_Array1D) {
			return dynamic_cast<C_ivec3Map_UI32插座*>(socket)->f_getData();
		}
	}
	return &m_Value;
}

void C_ivec3Map_UI32插座::f_setData(void * data, int64 ID)
{
}

PyObject* C_ivec3Map_UI32插座::f_输出_bl数据(PyObject* bl_data) {
	auto& v = *DEF_取ivec3Map_UI32插座数据(this);

	PyObject* data = PyList_New(v.size());

	if (bl_data == (PyObject*)0xffffffff) {
		int32 i = 0;
		for (auto& k : v) {
			PyObject* e = PyTuple_New(4);
			PyTuple_SetItem(e, 0, f_string转PyObject("key:"));
			//PyObject* co = PyTuple_New(3);
			PyTuple_SetItem(e, 1, Py_BuildValue("(i,i,i)", k.first.x, k.first.y, k.first.z));
			PyTuple_SetItem(e, 2, f_string转PyObject(" value:"));
			PyTuple_SetItem(e, 3, Py_BuildValue("i", k.second));

			PyList_SetItem(data, i, e);
			++i;
		}
	}

	return data;
}














C_uint64Map插座_UI32_Array1D::C_uint64Map插座_UI32_Array1D(string name)
	:C_插座基类(name, E_插座类型::e_插座Type_MapiVec3_Uint32_Array1D)
{

}

C_uint64Map插座_UI32_Array1D::~C_uint64Map插座_UI32_Array1D() {

}

void* C_uint64Map插座_UI32_Array1D::f_getData() {
	C_插座基类* socket = f_getLinkOutSocket();
	if (socket) {
		if (socket->m_Type == E_插座类型::e_插座Type_MapiVec3_Uint32_Array1D) {
			return dynamic_cast<C_uint64Map插座_UI32_Array1D*>(socket)->f_getData();
		}
	}
	return &m_Value;
}

void C_uint64Map插座_UI32_Array1D::f_setData(void * data, int64 ID) {

}



PyObject * C_uint64Map插座_UI32_Array1D::f_输出_bl数据(PyObject * bl_data) {
	auto& v = *DEF_取uint64Map_ArrayUI32插座数据(this);

	PyObject* data = PyList_New(v.size());

	if (bl_data == (PyObject*)0xffffffff) {
		int32 i = 0;
		for (auto& k : v) {
			PyObject* e = PyTuple_New(4);
			PyTuple_SetItem(e, 0, f_string转PyObject("key:"));
			//PyObject* co = PyTuple_New(3);
			ivec3 key = f_UpPackData3X64(k.first);
			PyTuple_SetItem(e, 1, Py_BuildValue("(i,i,i)", key.x, key.y, key.z));
			PyTuple_SetItem(e, 2, f_string转PyObject(" value:"));

			PyObject* index = PyList_New(k.second.size());
			uint32 indexOffset = 0;
			for (const auto& ie : k.second) {
				PyList_SetItem(index, indexOffset, Py_BuildValue("i", ie));
				++indexOffset;
			}
			PyTuple_SetItem(e, 3, index);

			PyList_SetItem(data, i, e);
			++i;
		}
	}

	return data;
}















